/*******************************************************************************
* 1. 시 스 템 : 농협보험 이미지처리 시스템
* 2. 프로그램 : LIClmDstbtThread.java
* 3. 개 요    : 생명사고지급 분배 Agent
* 4. 작 성 자 : Son young hwee
* 5. 작 성 일 : 2011. 11. 01
* 6. 소스버전 : 1.0
********************************************************************************/

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import com.nhim.common.EnvManager;
import com.nhim.common.Environment;
import com.nhim.pool.ConnectionPool;
import com.nhim.common.NextJdgNo;
import com.nhim.utility.COMUtil;
import com.nhim.utility.STRUtil;

public class LIClmDstbtThread extends Thread{

	String agentName = "NHImDstbtAgent";
	String moduleName = "LIClmDstbtThread";
	String server = "";
	String agentTime = "";
	
	/**
	 * 생성자
	 *
	 */
	public LIClmDstbtThread(){
	}
	
	/**
	 * 생명사고 심사자분배 Agent 초기화
	 * @param agentName
	 * @param moduleName
	 */
	public void init(String agentTime){

		try{
			Environment env = EnvManager.getEnvironment();
			this.agentTime = agentTime;
			this.server = COMUtil.HOSTNAME;
			
			//Agent_Dao_Model model = new Agent_Dao_Model();		
			HashMap<String, Object> argInfoVO = new HashMap<String, Object>();
			argInfoVO.put("AGENT_NAME", agentName);
			argInfoVO.put("MODULE_NAME", moduleName);
			argInfoVO.put("SERVER_NAME", server);
			argInfoVO.put("AGENT_TIME", this.agentTime);
			ArrayList<HashMap<String, Object>> alist = getAgentTime();
			for(int i=0; i< alist.size(); i++){
				HashMap<String, Object> map= (HashMap<String, Object>)alist.get(i);
				int time = Integer.parseInt((String)map.get("TIME"));	
				COMUtil.debug("[LIClmDstbtThread] time :: " + time + " = agentTime :: " + agentTime);
				if(time > Integer.parseInt(agentTime)*5){
					updateData(argInfoVO);
				}
			}
			
		}catch(Exception e){
			COMUtil.debug("[init] Exception : " + e.toString());
		}
	}
	
	public ArrayList<HashMap<String, Object>> getAgentTime() throws Exception {
		
		ArrayList<HashMap<String, Object>> alist = new ArrayList<HashMap<String, Object>>();
		
		Connection oConn = null;
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
				
		COMUtil.debug(">>> [getAgentTime] Start... <<<");
		
		try{
			oConn = ConnectionPool.getConnection();
			COMUtil.debug(">>> DB Connection Success!!<<<");
			
			sbQuery.append("\n  SELECT round((sysdate- to_date(END_REG_DT, 'YYYYMMDDHH24MISS'))* 24 * 60 * 60) as TIME,		");
			sbQuery.append("\n  		SERVER_NAME ,																			");
			sbQuery.append("\n  		AGENT_TIME 																				");
			sbQuery.append("\n  FROM CO_AGENT_MNG 																		");
			sbQuery.append("\n  WHERE AGENT_NAME = ? 																			");
			sbQuery.append("\n      AND MODULE_NAME = ?																			");
			
			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			int i=1;
			pstmt.setString(i++, agentName);
			pstmt.setString(i++, moduleName);
			rs = pstmt.executeQuery();
			
			while (rs.next()){
				HashMap<String, Object> reMap = new HashMap<String, Object>();
				reMap.put("TIME", rs.getString("TIME"));
				reMap.put("SERVER_NAME", rs.getString("SERVER_NAME"));
				reMap.put("AGENT_TIME", rs.getInt("AGENT_TIME"));
				alist.add(reMap);
			}	
		}
		catch(Exception e) {
			COMUtil.debug("[getAgentTime] Exception : " + e.toString());
			throw new Exception("[getAgentTime] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
			if(oConn != null){ ConnectionPool.close(oConn); oConn=null;}
		}
		
		COMUtil.debug(">>> [getAgentTime] End... <<<");

		return alist;
	}
	
	
	public int updateData(HashMap<String, Object> argInfoVO) throws Exception {
		int returnVal=0;
		
		Connection oConn = null;
		PreparedStatement pstmt = null;		
		ResultSet rs = null;

		StringBuffer sbQuery = new StringBuffer();

		COMUtil.debug(">>> [updateData] Start... <<<");
		
		try{
			oConn = ConnectionPool.getConnection();
			
			sbQuery.append("\n  UPDATE CO_AGENT_MNG SET								");
			sbQuery.append("\n  	SERVER_NAME = ?	,										");
			sbQuery.append("\n  	AGENT_TIME = ?	,										");
			sbQuery.append("\n  	STRT_REG_DT = to_char(sysdate, 'YYYYMMDDHH24MISS'),	");
			sbQuery.append("\n  	END_REG_DT = to_char(sysdate, 'YYYYMMDDHH24MISS')		");
			sbQuery.append("\n  WHERE AGENT_NAME = ?										");
			sbQuery.append("\n      AND MODULE_NAME = ?										");

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			int i=1;
			pstmt.setString(i++, (String)argInfoVO.get("SERVER_NAME"));
			pstmt.setString(i++, (String)argInfoVO.get("AGENT_TIME"));
			pstmt.setString(i++, (String)argInfoVO.get("AGENT_NAME"));
			pstmt.setString(i++, (String)argInfoVO.get("MODULE_NAME"));
			
			returnVal= pstmt.executeUpdate();
		}
		catch(Exception e){
			COMUtil.debug("[updateData] Exception : " + e.toString());
			throw new Exception("[updateData] Exception:"+e.toString());
		}
		finally{
			if(rs != null){ rs.close(); rs=null;} 
			if(pstmt != null){ pstmt.close(); pstmt=null;} 
			if(oConn != null){ ConnectionPool.close(oConn); oConn=null;}
		}
		
		COMUtil.debug(">>> [updateData] End... <<<");
		
		return returnVal;
	}
	
	public Object updateEndProcDtm(HashMap<String, Object> argInfoVO) throws Exception {
		Object returnVal=0;
		
		Connection oConn = null;
		PreparedStatement pstmt = null;		
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
	
		COMUtil.debug(">>> [updateEndProcDtm] Start... <<<");
		
		try{
			oConn = ConnectionPool.getConnection();
			
			sbQuery.append("\n  UPDATE CO_AGENT_MNG SET								");
			sbQuery.append("\n  	END_REG_DT = to_char(sysdate, 'YYYYMMDDHH24MISS')		");
			sbQuery.append("\n  WHERE AGENT_NAME = ?										");
			sbQuery.append("\n      AND MODULE_NAME = ?										");

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			int i=1;
			pstmt.setString(i++, (String)argInfoVO.get("AGENT_NAME"));
			pstmt.setString(i++, (String)argInfoVO.get("MODULE_NAME"));
			returnVal= pstmt.executeUpdate();
		}
		catch(Exception e){
			COMUtil.debug("[updateEndProcDtm] Exception : " + e.toString());
			throw new Exception("[updateEndProcDtm] Exception:"+e.toString());
		}
		finally{
			if(rs != null){ rs.close(); rs=null;} 
			if(pstmt != null){ pstmt.close(); pstmt=null;} 
			if(oConn != null){ ConnectionPool.close(oConn); oConn=null;}
		}
		
		COMUtil.debug(">>> [updateEndProcDtm] End... <<<");
		
		return returnVal;
	}	

	/**
	 * run 함수
	 * 구동중인 서버 정보를 가지고 ACTIVE인지 SLEEP인지 인식
	 * 
	 */
	public void run(){
		
		
		try{
			HashMap<String, Object> argInfoVO = new HashMap<String, Object>();
			argInfoVO.put("AGENT_NAME", agentName);
			argInfoVO.put("MODULE_NAME", moduleName);

			ArrayList<HashMap<String, Object>> alist = null;
			while(true){
				alist = getAgentTime();
				for(int i=0; i< alist.size(); i++){
					HashMap<String, Object> map= (HashMap<String, Object>)alist.get(i);
					String serverName=(String)map.get("SERVER_NAME");
					int time = Integer.parseInt((String)map.get("TIME"));
					
					if(time > Integer.parseInt(agentTime)*3){
						init(agentTime);
					}
					
					if(serverName.equals(server)){
						getDstbtData();
						updateEndProcDtm(argInfoVO);
					}
				}
				alist=null;
				Thread.sleep(Integer.parseInt(agentTime)*1000);
			}			
		}catch(Exception e){
			COMUtil.debug("[run-LIClmDstbtThread] Exception : " + e.toString());
		}
		
		/*
		try{
			String agentTime = COMUtil.LICLM_AGENT_SLEEP_TIME;
			this.server = COMUtil.HOSTNAME;
			while(true) {
				getDstbtData();
				
				sleep(Integer.parseInt(agentTime) * 1000);
			}
			
		}
		catch(Exception e) {
			COMUtil.debug("[run-LIClmDstbtThread] Exception : " + e.toString());
		}
		*/
	}
	
	/**
	 * 심사배분대상 조회
	 *
	 */
	public void getDstbtData(){
		try{
			//Card_Agent_Dctm_Model model = new Card_Agent_Dctm_Model();
			ArrayList<HashMap<String, Object>> alist = getLiClmDstbt();	
			COMUtil.debug("LICLM Dstbt Count :: " + alist.size());
			if(alist != null){
	          	for(int i=0; i<alist.size(); i++){
	          		HashMap<String, Object> amap= (HashMap<String, Object>)alist.get(i);
	          		process(amap);
	          	}			
			}	
		}catch(Exception e){
			COMUtil.debug("[getDstbtData] Exception : " + e.toString());
		}	
		
	}
	
	public ArrayList<HashMap<String, Object>> getLiClmDstbt() throws Exception {
		
		ArrayList<HashMap<String, Object>> alist = new ArrayList<HashMap<String, Object>>();
		
		Connection oConn = null;
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
				
		COMUtil.debug(">>> [getLiClmDstbt] Start... <<<");
		
		try{
			oConn = ConnectionPool.getConnection();
			COMUtil.debug(">>> DB Connection Success!!<<<");
/* 금액기준			
			sbQuery.append("\n	SELECT a.RECP_NO, ");
			sbQuery.append("\n  		a.INSURANT_RNMNO,			");																		
			sbQuery.append("\n  		a.RECP_DATE,				"); 
			sbQuery.append("\n  		a.RECP_SEQ,					"); 
			sbQuery.append("\n  		a.ACDT_RECP_SEQ,			"); 
			sbQuery.append("\n  		a.ROLE_AUTHY_OFFICE_CODE,	"); 
			sbQuery.append("\n  		a.LEGACY_RECP_KEY,			"); 
			sbQuery.append("\n  		a.JDG_NO,  					"); 			
			sbQuery.append("\n  		c.RECP_OFFICE_CODE,			"); 
			sbQuery.append("\n  		c.RECP_RGNOFC_CODE,			"); 
			sbQuery.append("\n  		(select substr(code_expl,0,6) from co_code where grp_code in ('240000', '241000', '242000', '243000') and code = c.RECP_RGNOFC_CODE ) RECP_REGN_CODE, "); 
			sbQuery.append("\n  		SUM(b.GUAR_AMT) GUAR_AMT	"); 
			sbQuery.append("\n  FROM LI_CLM_020 a, LI_CLM_030 b, LI_CLM_010 c ");
			sbQuery.append("\n  WHERE a.RECP_NO = b.RECP_NO			");	
			sbQuery.append("\n      AND a.RECP_NO = c.RECP_NO		");
			sbQuery.append("\n      AND a.USE_TYPE = '1'			");
			sbQuery.append("\n      AND (JDG_NO IS NULL or JDG_NO = '99') ");		// 99 - 재분배 대상
			sbQuery.append("\n      AND C.IMAGE_KEY IS NOT NULL 	");
			sbQuery.append("\n  GROUP BY a.RECP_NO, a.INSURANT_RNMNO, a.RECP_DATE, a.RECP_SEQ, 	");
			sbQuery.append("\n			a.ACDT_RECP_SEQ, a.ROLE_AUTHY_OFFICE_CODE, a.LEGACY_RECP_KEY, 	");
			sbQuery.append("\n			c.RECP_OFFICE_CODE, c.RECP_RGNOFC_CODE, a.JDG_NO, RECP_REGN_CODE ");
*/		
			// 20111220 modified by Badboy : 직무권한 기준으로 변경
			sbQuery.append("\n	SELECT a.RECP_NO, ");
			sbQuery.append("\n  		a.INSURANT_RNMNO,			");																		
			sbQuery.append("\n  		a.RECP_DATE,				"); 
			sbQuery.append("\n  		a.RECP_SEQ,					"); 
			sbQuery.append("\n  		a.ACDT_RECP_SEQ,			"); 
			sbQuery.append("\n  		a.ROLE_AUTHY_OFFICE_CODE,	"); 
			sbQuery.append("\n  		a.LEGACY_RECP_KEY,			"); 
			sbQuery.append("\n  		a.JDG_NO,  					"); 
			sbQuery.append("\n  		a.ROLE_AUTHY,  				"); 			
			sbQuery.append("\n  		b.RECP_OFFICE_CODE,			"); 
			sbQuery.append("\n  		b.RECP_RGNOFC_CODE,			"); 
			sbQuery.append("\n  		(select substr(code_expl,0,6) from co_code where grp_code in ('240000', '241000', '242000', '243000') and code = b.RECP_RGNOFC_CODE ) RECP_REGN_CODE "); 
			sbQuery.append("\n  FROM LI_CLM_020 a, LI_CLM_010 b ");
			sbQuery.append("\n  WHERE 1=1							");	
			sbQuery.append("\n      AND a.RECP_NO = b.RECP_NO		");
			sbQuery.append("\n      AND a.USE_TYPE = '1'			");
			sbQuery.append("\n      AND (JDG_NO IS NULL or JDG_NO = '99') ");		// 99 - 재분배 대상
			sbQuery.append("\n      AND b.IMAGE_KEY IS NOT NULL 	");
			
			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();

			rs = pstmt.executeQuery();
			while (rs.next()){
				HashMap<String, Object> reMap = new HashMap<String, Object>();
				reMap.put("RECP_NO", 				rs.getString("RECP_NO"));
				reMap.put("INSURANT_RNMNO", 		rs.getString("INSURANT_RNMNO"));
				reMap.put("RECP_DATE", 				rs.getString("RECP_DATE"));
				reMap.put("RECP_SEQ", 				rs.getString("RECP_SEQ"));
				reMap.put("ACDT_RECP_SEQ", 			rs.getString("ACDT_RECP_SEQ"));
				reMap.put("ROLE_AUTHY_OFFICE_CODE", rs.getString("ROLE_AUTHY_OFFICE_CODE"));
				reMap.put("LEGACY_RECP_KEY", 		rs.getString("LEGACY_RECP_KEY"));
				reMap.put("RECP_OFFICE_CODE", 		rs.getString("RECP_OFFICE_CODE"));
				reMap.put("RECP_RGNOFC_CODE", 		rs.getString("RECP_RGNOFC_CODE"));
				reMap.put("RECP_REGN_CODE", 		rs.getString("RECP_REGN_CODE"));
				//reMap.put("GUAR_AMT", 				rs.getString("GUAR_AMT"));			2011.12.20 deleted by Badboy : 금액기준 제거
				reMap.put("ROLE_AUTHY", 			rs.getString("ROLE_AUTHY"));
				reMap.put("JDG_NO", 				STRUtil.NVL(rs.getString("JDG_NO"),""));
				
				alist.add(reMap);
			}	
		}
		catch(Exception e) {
			COMUtil.debug("[getLiClmDstbt] Exception : " + e.toString());
			throw new Exception("[getLiClmDstbt] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
			if(oConn != null){ ConnectionPool.close(oConn); oConn=null;}
		}
		
		COMUtil.debug(">>> [getLiClmDstbt] End... <<<");

		return alist;
	}

    /**
     * 생명사고심사자 분배
     * 1. 분배대상 심사자 조회
     * 2. LI_IMN_010, LI_CLM_020 업데이트
     * 3. LI_CLM_070 Insert
     * @param HashMap<String, Object> amap
     * @return
     */	
	public void process(HashMap<String, Object> amap) throws Exception {
		
		COMUtil.debug(">>> ==================== Process from " + server + "  Start =====================<<<");
		
		Connection oConn = null;
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
				
		COMUtil.debug(">>> [process] Start... <<<");
		COMUtil.debug(">>> [process] RECP_NO => "+ (String)amap.get("RECP_NO") + " <<<");
		
		String sJdgNo = (String)amap.get("JDG_NO");		// 재 분배 대상건 여부 확인을 위함
		
		//long nGuarAmt = Long.parseLong((String)amap.get("GUAR_AMT"));
		String sRoleAuthy		= (String)amap.get("ROLE_AUTHY");
		String sRecpRgnofcCode 	= (String)amap.get("RECP_RGNOFC_CODE");
		String sRecpRegnCode 	= (String)amap.get("RECP_REGN_CODE");
		String sNextJdgNo = "";
		
		//2011.12.20 modified by Badboy : 금액기준 --> 직무권한으로 구분 변경
		String sJdgGroup = "";			// 심사그룹

		if("3".equals(sRoleAuthy)) 		// 중앙본부
			sJdgGroup = "30";
		else if("2".equals(sRoleAuthy))	// 지역본부 
			sJdgGroup = "20";
		else if("4".equals(sRoleAuthy))	// 아웃소싱
			sJdgGroup = "40";		
		else
			sJdgGroup = "10";			// 심사센터
		
		try{
			oConn = ConnectionPool.getConnection();
			COMUtil.debug(">>> DB Connection Success!!<<<");
			oConn.setAutoCommit(false);
			
			COMUtil.debug(">>> sJdgGroup = "+ sJdgGroup + " <<<");
			if("20".equals(sJdgGroup))	{ //지역본부, 심사센터
				sNextJdgNo = NextJdgNo.getNextJdgNo2(oConn, sJdgGroup, sRecpRgnofcCode, sRecpRegnCode);
			}
			else {
				sNextJdgNo = NextJdgNo.getNextJdgNo(oConn, sJdgGroup, sRecpRgnofcCode, sRecpRegnCode);
			}
			
			if(!"".equals(sNextJdgNo)) {	// 분배대상자 지정 성공
				//재분배 대상건 일 경우
				if("99".equals(sJdgNo)) {
					COMUtil.debug(">>> [process] Re-Dstbt <<<");
					int nRtn = procReDstbt(oConn, sNextJdgNo, sJdgGroup, amap);
					if(nRtn < 1) {
						COMUtil.debug(" [process] Re-Dstbt Failed !!! <<<");
						if(oConn != null) {
							oConn.rollback();
							oConn.setAutoCommit(true);
						}
					}
					else {
						COMUtil.debug(" [process] Re-Dstbt Success !!! <<<");
						oConn.commit();
						oConn.setAutoCommit(true);
					}
				}
				//최초 분배 대상
				else {
					int nRtn = updateJdgNoInfo(oConn, sNextJdgNo, sJdgGroup, amap );
					if(nRtn < 1) {
						if(oConn != null) {
							oConn.rollback();
							oConn.setAutoCommit(true);
						}
					}
					else {
						oConn.commit();
						oConn.setAutoCommit(true);
					}
					COMUtil.debug("updateJdgNoInfo=>nRtn = " + nRtn);
				}
			}
			else {
				COMUtil.debug(">>> [process] Failed LI_CLM Dstbt Process ..." + (String)amap.get("RECP_NNO") + " <<<");
				if(oConn != null) {
					oConn.rollback();
					oConn.setAutoCommit(true);
				}
			}
			
		}
		catch(Exception e){
			COMUtil.debug("[process] Exception : " + e.toString());
			if(oConn != null) {
				oConn.rollback();
				oConn.setAutoCommit(true);
			}
			throw new Exception("[process] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
			if(oConn != null){ ConnectionPool.close(oConn); oConn=null;}
		}
		
		COMUtil.debug(">>> ==================== Process End !!! =====================<<<");

	}

	public int procReDstbt(Connection oConn,String sNextJdgNo, String sJdgGroup, HashMap<String, Object> amap) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
		
		String recpNo = STRUtil.NVL((String)amap.get("RECP_NO"), "");
		
		COMUtil.debug(">>> [procReDstbt:"+recpNo+"] Start... <<<");
		COMUtil.debug(">>> sNextJdgNo="+sNextJdgNo+"<<<");
		
		try{
			//심사상태코드 조회 : 70(결재)이상이면 재분배 취소
			String sJdgmtStat = getJdgmtStat(oConn, recpNo);
			if(Integer.parseInt(sJdgmtStat) >= 70) {
				COMUtil.debug(">>> [procReDstbt] Cannot Re-Dstbt : JdgmtStat = " + sJdgmtStat + " <<<");
				return nRtn;
			}
			
			//1. LI_CLM_020 update
			sbQuery.append("\n	UPDATE LI_CLM_020 ");
			sbQuery.append("\n  	SET JDG_NO = ? 			");				
			sbQuery.append("\n  WHERE RECP_NO = ?			");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, sNextJdgNo);
			pstmt.setString(2, recpNo);
			nRtn = pstmt.executeUpdate();
			if(pstmt != null) { pstmt.close(); pstmt = null; }
			
			//2. LI_CLM_070 delete & update
			nRtn = deleteLiClm070(oConn, recpNo);
			if(nRtn <= 0) {
				COMUtil.debug("[updateJdgNoInfo] delete LI_CLM_070 Failed!!! ");
				return nRtn;
			}

			nRtn = updateLiClm070(oConn, sNextJdgNo, recpNo);
			if(nRtn <= 0) {
				COMUtil.debug("[updateJdgNoInfo] update LI_CLM_070 Failed!!! ");
				return nRtn;
			}
			nRtn = deleteLiClm110(oConn, recpNo);
			if(nRtn <= 0) {
				COMUtil.debug("[updateJdgNoInfo] delete LI_CLM_110 Failed!!! ");
				return nRtn;
			}
			nRtn = updateLiClm110(oConn, sNextJdgNo, recpNo, amap);
			if(nRtn <= 0) {
				COMUtil.debug("[updateJdgNoInfo] update LI_CLM_110 Failed!!! ");
				return nRtn;
			}
			
			nRtn = updateLiClm010(oConn, recpNo);
			if(nRtn <= 0) {
				COMUtil.debug("[updateLiClm010] update LI_CLM_010 Failed!!! ");
				return nRtn;
			}
			
			deleteLiClm120(oConn, recpNo);	// 보완테이블
			deleteLiClm130(oConn, recpNo);	// 보류테이블
			deleteLiClm200(oConn, recpNo);	// 조사의뢰 테이블
			deleteLiClm210(oConn, recpNo);	// 조사결과 테이블
			deleteLiClm220(oConn, recpNo);	// 조사자 변경신청/승인 테이블
			deleteLiClm071(oConn, recpNo);	// 심사자 이관 테이블
			// 
			//진행이력 테이블 인서트
			//if(nRtn > 0) {
			//	nRtn = insertLiClm040(oConn, sNextJdgNo, recpNo, sr);
			//}
		}
		catch(Exception e) {
			COMUtil.debug("[updateJdgNoInfo] Exception : " + e.toString());
			throw new Exception("[updateJdgNoInfo] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public String getJdgmtStat(Connection oConn, String recpNo) throws Exception {
		
		String sJdgmtStat = "";
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [getJdgmtStat] Start... <<<");
		
		try{
			sbQuery.append("\n	SELECT JDGMT_STAT	");
			sbQuery.append("\n  FROM LI_CLM_110 	");	
			sbQuery.append("\n  WHERE RECP_NO = ?	");	
			
			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			rs = pstmt.executeQuery();
			
			if(rs.next()) {
				sJdgmtStat = STRUtil.NVL(rs.getString("JDGMT_STAT"), "");			// 심사상태코드
			}
		}
		catch(Exception e) {
			COMUtil.debug("[getJdgmtStat] Exception : " + e.toString());
			throw new Exception("[getJdgmtStat] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return sJdgmtStat;
		
	}
	
	public int deleteLiClm070(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm070:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_070 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm070] Exception : " + e.toString());
			throw new Exception("[deleteLiClm070] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	
	public int deleteLiClm110(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm110:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_110 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm110] Exception : " + e.toString());
			throw new Exception("[deleteLiClm110] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public int deleteLiClm120(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm120:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_120 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm120] Exception : " + e.toString());
			throw new Exception("[deleteLiClm120] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public int deleteLiClm130(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm130:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_130 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm130] Exception : " + e.toString());
			throw new Exception("[deleteLiClm130] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public int deleteLiClm071(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm071:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_071 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm071] Exception : " + e.toString());
			throw new Exception("[deleteLiClm071] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public int deleteLiClm200(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm200:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_200 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm200] Exception : " + e.toString());
			throw new Exception("[deleteLiClm200] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public int deleteLiClm210(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm210:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_210 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm210] Exception : " + e.toString());
			throw new Exception("[deleteLiClm210] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	public int deleteLiClm220(Connection oConn, String recpNo) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm220:"+recpNo+"] Start... <<<");
		
		try{
			
			sbQuery.append("\n	DELETE LI_CLM_220 	");			
			sbQuery.append("\n  WHERE RECP_NO = ?	");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm220] Exception : " + e.toString());
			throw new Exception("[deleteLiClm220] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	/**
	 * updateJdgNoInfo
	 * @param rmap
	 * @param amap
	 * @throws Exception
	 */
	public int updateJdgNoInfo(Connection oConn,String sNextJdgNo, String sJdgGroup, HashMap<String, Object> amap) throws Exception{
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
		
		String recpNo = STRUtil.NVL((String)amap.get("RECP_NO"), "");
		
		COMUtil.debug(">>> [updateJdgNoInfo:"+recpNo+"] Start... <<<");
		COMUtil.debug(">>> sNextJdgNo="+sNextJdgNo+"<<<");
		
		try{
			//1. LI_CLM_020 update
			sbQuery.append("\n	UPDATE LI_CLM_020 ");
			sbQuery.append("\n  	SET JDG_NO = ? 			");				
			sbQuery.append("\n  WHERE RECP_NO = ?			");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, sNextJdgNo);
			pstmt.setString(2, recpNo);
			nRtn = pstmt.executeUpdate();
			if(pstmt != null) { pstmt.close(); pstmt = null; }
			
			//2. LI_CLM_070 update
			nRtn = updateLiClm070(oConn, sNextJdgNo, recpNo);
			if(nRtn > 0) 
				nRtn = updateLiClm110(oConn, sNextJdgNo, recpNo, amap);
			
			nRtn = updateLiClm010(oConn, recpNo);
			
			//진행이력 테이블 인서트
			//if(nRtn > 0) {
			//	nRtn = insertLiClm040(oConn, sNextJdgNo, recpNo, sr);
			//}
		}
		catch(Exception e) {
			COMUtil.debug("[updateJdgNoInfo] Exception : " + e.toString());
			throw new Exception("[updateJdgNoInfo] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		return nRtn;
	}
	
	
	public int deleteLiClm070(Connection oConn, String sNextJdgNo, String recpNo) throws Exception{
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [deleteLiClm070:"+recpNo+"] Start... <<<");
		
		try{
			
			//2. LI_CLM_070 INSERT
			sbQuery.append("\n	DELETE LI_CLM_070 ( ");
			sbQuery.append("\n WHERE RECP_NO = ? ");

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);

			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[deleteLiClm070] Exception : " + e.toString());
			throw new Exception("[deleteLiClm070] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		COMUtil.debug(">>> [updateLiClm070] End... <<<");

		return nRtn;
	}
	/**
	 * updateLiClm070
	 * @param rmap
	 * @param amap
	 * @throws Exception
	 */
	public int updateLiClm070(Connection oConn, String sNextJdgNo, String recpNo) throws Exception{
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
		StringBuffer sbQuery2 = new StringBuffer();
		StringBuffer sbQuery3 = new StringBuffer();
		
		String chrgRgnofcCode = "";
		String chrgRegnCode = "";
		String onlnCode = "";
		String insurantRmnNo = "";
		String insurantName = "";
		String recpDate = "";
		String acdtDate = "";
		String reqOpr = "";
		
		COMUtil.debug(">>> [updateLiClm070] Start... <<<");
		
		try{
			// 1. 심사자정보 조회
			sbQuery.append("\n	SELECT  ");
			sbQuery.append("\n  	a.CHRG_RGNOFC_CODE, 			");						// 심사자 담당 지역본부코드
			sbQuery.append("\n  	NVL(CHRG_REGN_CODE,'') CHRG_REGN_CODE, ");				// 심사자 권역코드
			sbQuery.append("\n  	b.ONLN_CODE 					");						// 심사자 사무소코드(온라인코드)
			sbQuery.append("\n  FROM LI_IMN_010 a, CO_USER b		");	
			sbQuery.append("\n  WHERE a.JDG_NO = b.INDV_NO			");	
			sbQuery.append("\n      AND a.JDG_NO = ?		");

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, sNextJdgNo);
			rs = pstmt.executeQuery();
			
			if(rs.next()) {
				chrgRgnofcCode = STRUtil.NVL(rs.getString("CHRG_RGNOFC_CODE"), "");			// 담당지역본부코드
				chrgRegnCode = STRUtil.NVL(rs.getString("CHRG_REGN_CODE"), "");				// 담당 권역코드
				onlnCode = STRUtil.NVL(rs.getString("ONLN_CODE"), "");						// 온라인코드
			}
			if(rs != null) { rs.close(); rs = null; }
			if(pstmt != null) { pstmt.close(); pstmt = null; }
			
			// 2. 사고접수정보조회
			sbQuery2.append("\n	SELECT  ");
			sbQuery2.append("\n  	a.INSURANT_RNMNO, 			");		// 피보험자 실명번호
			sbQuery2.append("\n  	NVL(INSURANT_NAME,'') INSURANT_NAME,	");		// 피보험자 명
			sbQuery2.append("\n  	a.RECP_DATE, 				");		// 접수일자
			sbQuery2.append("\n  	a.ACDT_DATE, 				");		// 사고일자
			sbQuery2.append("\n  	a.REQ_OPR 					");		// 입력자코드(청구입력자)
			sbQuery2.append("\n  FROM LI_CLM_010 a				");	
			sbQuery2.append("\n  WHERE a.RECP_NO = ?			");	
	
			pstmt = oConn.prepareStatement(sbQuery2.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			rs = pstmt.executeQuery();

			if(rs.next()) {
				insurantRmnNo = STRUtil.NVL(rs.getString("INSURANT_RNMNO"), "");
				insurantName = STRUtil.NVL(rs.getString("INSURANT_NAME"), "");
				recpDate = STRUtil.NVL(rs.getString("RECP_DATE"), "");
				acdtDate = STRUtil.NVL(rs.getString("ACDT_DATE"), "");
				reqOpr = STRUtil.NVL(rs.getString("REQ_OPR"), "");
			}
			
			COMUtil.debug(">>> recpNo="+recpNo);
			COMUtil.debug(">>> sNextJdgNo="+sNextJdgNo);
			COMUtil.debug(">>> reqOpr="+reqOpr);
			
			//2. LI_CLM_070 INSERT
			sbQuery3.append("\n	INSERT INTO LI_CLM_070 ( ");
			sbQuery3.append("\n  	RECP_NO, JDG_NO, JDG_REGN_CODE, JDG_RGNOFC_CODE, ");
			sbQuery3.append("\n  	JDG_OFFICE_CODE, INSURANT_RNMNO, INSURANT_NAME, RECP_DATE, ");
			sbQuery3.append("\n  	DISTB_DATE, ACDT_DATE, DEL_YN, REG_DT, REG_MN_NO ");
			sbQuery3.append("\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, TO_CHAR(SYSDATE, 'YYYYMMDD'), ?, 'N', TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS'), ?)		");	

			pstmt = oConn.prepareStatement(sbQuery3.toString());
			pstmt.clearParameters();
			int i=1;
			pstmt.setString(i++, recpNo);
			pstmt.setString(i++, sNextJdgNo);
			pstmt.setString(i++, chrgRegnCode);
			pstmt.setString(i++, chrgRgnofcCode);
			pstmt.setString(i++, onlnCode);
			pstmt.setString(i++, insurantRmnNo);
			pstmt.setString(i++, insurantName);
			pstmt.setString(i++, recpDate);
			pstmt.setString(i++, acdtDate);
			pstmt.setString(i++, reqOpr);

			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[updateLiClm070] Exception : " + e.toString());
			throw new Exception("[updateLiClm070] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		COMUtil.debug(">>> [updateLiClm070] End... <<<");
		return nRtn;
	}	
	
	/**
	 * updateLiClm110
	 * @param rmap
	 * @param amap
	 * @throws Exception
	 */
	public int updateLiClm110(Connection oConn, String sNextJdgNo, String recpNo, HashMap<String, Object> amap) throws Exception{
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbQuery = new StringBuffer();
		StringBuffer sbQuery2 = new StringBuffer();
		StringBuffer sbQuery3 = new StringBuffer();
		
		COMUtil.debug(">>> [updateLiClm110] Start... <<<");
		
		String insurantRmnNo = (String)amap.get("INSURANT_RNMNO");
		String acdtRecpSeq = (String)amap.get("ACDT_RECP_SEQ");
		acdtRecpSeq = ("00" + acdtRecpSeq).substring(acdtRecpSeq.length());
		
		String acdtRecpNo = insurantRmnNo + acdtRecpSeq;					//신공제청구번호
		COMUtil.debug(">>> acdtRecpNo =>"+acdtRecpNo);
		
		String jdgName = "";					//심사자명
		String jdgTelNo = "";					//심사자전화번호
		String jdgHpNo = "";					//심사자휴대전화번호
		String acdtDate = "";					//사고일자
		String trtBrno = "";					//취급점번호
		String oprIdCard = "";					//조작자ID카드
		String dutyMnIdCard = "";				//책임자ID카드
		String tmnlNo = "";						//단말기번호
		String reqOpr = "";						//입력자코드(청구입력자)

		try{
			// 1. 심사자정보 조회
			sbQuery.append("\n	SELECT  ");
			sbQuery.append("\n  	NVL(JDG_NM, '') JDG_NM, 				");		// 심사자명
			sbQuery.append("\n  	NVL(OFFICE_TELNO, '') OFFICE_TELNO, 	");		// 심사자전화번호
			sbQuery.append("\n  	NVL(HP_TELNO, '') HP_TELNO 			");		// 심사자 휴대폰번호
			sbQuery.append("\n  FROM LI_IMN_010		");	
			sbQuery.append("\n  WHERE JDG_NO = ?			");	

			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			pstmt.setString(1, sNextJdgNo);
			rs = pstmt.executeQuery();
			
			if(rs.next()) {
				jdgName = STRUtil.NVL(rs.getString("JDG_NM"), "");
				jdgTelNo = STRUtil.NVL(rs.getString("OFFICE_TELNO"), "");
				jdgHpNo = STRUtil.NVL(rs.getString("HP_TELNO"), "");
			}
			if(rs != null) { rs.close(); rs = null; }
			if(pstmt != null) { pstmt.close(); pstmt = null; }
			
			// 2. 사고접수정보조회
			sbQuery2.append("\n	SELECT  ");
			sbQuery2.append("\n  	ACDT_DATE, 					");		// 사고일자
			sbQuery2.append("\n  	TRTBR_NO, 					");		// 취급점번호
			sbQuery2.append("\n  	OPR_ID_CARD, 				");		// 조작자ID카드
			sbQuery2.append("\n  	DUTYMN_ID_CARD, 			");		// 책임자ID카드
			sbQuery2.append("\n  	TMNL_NO, 					");		// 사고일자
			sbQuery2.append("\n  	REQ_OPR 					");		// 입력자코드(청구입력자)
			sbQuery2.append("\n  FROM LI_CLM_010				");	
			sbQuery2.append("\n  WHERE RECP_NO = ?			");	
	
			pstmt = oConn.prepareStatement(sbQuery2.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			rs = pstmt.executeQuery();

			if(rs.next()) {
				acdtDate = STRUtil.NVL(rs.getString("ACDT_DATE"), "");
				trtBrno = STRUtil.NVL(rs.getString("TRTBR_NO"), "");
				oprIdCard = STRUtil.NVL(rs.getString("OPR_ID_CARD"), "0");
				dutyMnIdCard = STRUtil.NVL(rs.getString("DUTYMN_ID_CARD"), "");
				tmnlNo = STRUtil.NVL(rs.getString("TMNL_NO"), "");
				reqOpr = STRUtil.NVL(rs.getString("REQ_OPR"), "");
			}
			
			//3. LI_CLM_110 INSERT
			// 20111208 modified by Badboy : ASGN_DATE 추가
			sbQuery3.append("\n	INSERT INTO LI_CLM_110 ( ");
			sbQuery3.append("\n  	RECP_NO, ACDT_RECP_NO, JDGMT_STAT, JDG_NO, JDG_NM, JDG_TELNO, JDG_HP_TELNO, ");
			sbQuery3.append("\n  	ACDT_DATE, PROC_DT, TRTBR_NO, OPR_ID_CARD, DUTYMN_ID_CARD, TMNL_NO, ");
			sbQuery3.append("\n  	DEL_YN, REG_DT, REG_MN_NO, ACDT_PROC_CODE, PROC_RSLT_CODE, ASGN_DATE ");
			sbQuery3.append("\n ) VALUES (?, ?, '30', ?, ?, ?, ?, ?, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS'), ?, ?, ?, ?, ");
			sbQuery3.append("\n			'N', TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS'), ?, '30', '00', TO_CHAR(SYSDATE, 'YYYYMMDD') )	");	

			pstmt = oConn.prepareStatement(sbQuery3.toString());
			pstmt.clearParameters();
			int i=1;
			pstmt.setString(i++, recpNo);
			pstmt.setString(i++, acdtRecpNo);
			pstmt.setString(i++, sNextJdgNo);
			pstmt.setString(i++, jdgName);
			pstmt.setString(i++, jdgTelNo);
			pstmt.setString(i++, jdgHpNo);
			pstmt.setString(i++, acdtDate);
			pstmt.setString(i++, trtBrno);
			pstmt.setString(i++, oprIdCard);
			pstmt.setString(i++, dutyMnIdCard);
			pstmt.setString(i++, tmnlNo);
			pstmt.setString(i++, reqOpr);			

			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[updateLiClm110] Exception : " + e.toString());
			throw new Exception("[updateLiClm110] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		COMUtil.debug(">>> [updateLiClm110] End... <<<");
		return nRtn;
	}
	
	/**
	 * updateLiClm110
	 * @param rmap
	 * @param amap
	 * @throws Exception
	 */
	public int updateLiClm010(Connection oConn, String recpNo) throws Exception{
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		ResultSet rs = null;
		
		StringBuffer sbUpdate = new StringBuffer();
		
		COMUtil.debug(">>> [updateLiClm010] Start... <<<");
				
		try{
			sbUpdate.append("\n	UPDATE LI_CLM_010 ");
			sbUpdate.append("\n  	SET RECP_STAT_CODE = '30'	");				
			sbUpdate.append("\n  WHERE RECP_NO = ?			");
			
			pstmt = oConn.prepareStatement(sbUpdate.toString());
			pstmt.clearParameters();
			pstmt.setString(1, recpNo);
			nRtn = pstmt.executeUpdate();
		}
		catch(Exception e) {
			COMUtil.debug("[updateLiClm010] Exception : " + e.toString());
			throw new Exception("[updateLiClm010] Exception:"+e.toString());
		}
		finally {
			if(rs != null) { rs.close(); rs=null;}
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		COMUtil.debug(">>> [updateLiClm010] End... <<<");
		return nRtn;
	}
	
/*
	public static int insertLiClm040(Connection oConn, String reqOpr, String bizKey, SocketMessage sr) throws Exception {
		
		int nRtn = 0;
		
		PreparedStatement pstmt = null;	
		StringBuffer sbQuery = new StringBuffer();
		
		COMUtil.debug(">>> [insertLiClm040] Start... <<<");
		
		try {
			sbQuery.append("\n  INSERT INTO LI_CLM_040  	");
			sbQuery.append("\n  (  							");			
			sbQuery.append("\n 		RECP_NO,			");
			sbQuery.append("\n 		PROC_DT,			");
			sbQuery.append("\n 		PROCMN_NO,			");
			sbQuery.append("\n 		PROC_OFFICE_CODE,	");			
			sbQuery.append("\n 		RECP_STAT_CODE,		");
			sbQuery.append("\n 		ACDT_PROC_CODE		");
			sbQuery.append("\n  ) values (					");
			sbQuery.append("\n  	?,TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISSFF3'),?,?,?,? ");
			sbQuery.append("\n  )							");
			
			pstmt = oConn.prepareStatement(sbQuery.toString());
			pstmt.clearParameters();
			int i=1;
			pstmt.setString(i++, bizKey);
			pstmt.setString(i++, new String(sr.getIndvNo()));
			pstmt.setString(i++, new String(sr.getOnlineCode()));			
			pstmt.setString(i++, "10");	//접수상태
			pstmt.setString(i++, "11");	//스캔처리		
			
			nRtn = pstmt.executeUpdate();
			if(nRtn > 0) {
				pstmt.close();
				pstmt = oConn.prepareStatement(sbQuery.toString());
				pstmt.clearParameters();
				i=1;
				pstmt.setString(i++, bizKey);
				pstmt.setString(i++, reqOpr);
				pstmt.setString(i++, new String(sr.getOnlineCode()));			
				pstmt.setString(i++, "20");	//청구상태
				pstmt.setString(i++, "20");	//청구처리
				
				nRtn = pstmt.executeUpdate();
			}

		}
		catch(Exception e) {
			COMUtil.debug("[insertLiClm040] Exception : " + e.toString());
			throw new Exception("[insertLiClm040] Exception:"+e.toString());
		}
		finally {
			if(pstmt != null){ pstmt.close(); pstmt=null;}
		}
		
		COMUtil.debug(">>> [insertLiClm040] End... <<<");
		
		return nRtn;
	}
*/
}
